#ifndef RL_REWARD_ENGINE_H
#define RL_REWARD_ENGINE_H

#include "algohub_common_type.h"
#include "RLPlatformData.h"
#include <vector>
#include <tuple>

namespace algo
{
    // Forward declaration to break circular dependency
    class RLPlanningEngine;

    class RLRewardEngine
    {
    public:
        RLRewardEngine(const RLPlatformData& platformData, const algobase::RLConfig& config, const RLPlanningEngine& planningEngine);
        ~RLRewardEngine();

        std::vector<double> calculateReward(int ix, int iy, int iz, int lastAction, int currentAction, const std::tuple<int, int, int>& end_grid);

    private:
        // Hard Constraints
        double checkHardConstraints(int ix, int iy, int iz);

        // Soft Constraints / Rewards
        double calculateSafetyReward(int ix, int iy, int iz);
        double calculateHeuristicReward(int ix, int iy, int iz, int action, const std::tuple<int, int, int>& end_grid);
        double calculateTurnPenalty(int lastAction, int currentAction);
        double calculatePitchPenalty(int lastAction, int currentAction);

        const RLPlatformData& mPlatformData;
        const algobase::RLConfig& mConfig;
        const RLPlanningEngine& mPlanningEngine; // To access public helper methods like gridToWorld if needed
    };
}

#endif // !RL_REWARD_ENGINE_H